﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevComponents.DotNetBar.SuperGrid;

namespace Einstein.Utility
{
    public static class PrimaryGridExt
    {
        /// <summary>
        /// 获取选定行的实体对象
        /// </summary> 
        public static T GetModel<T>(this  GridPanel panel) where T : class
        {
            var selects = panel.GetSelectedRows();
            if (selects != null && selects.Count > 0)
            {
                GridRow select = selects[0] as DevComponents.DotNetBar.SuperGrid.GridRow;
                if (select != null)
                {
                    return select.DataItem as T;
                }
            }
            return null;
        } 
    }
}
